package com.lanxiao.cloud.modules.gateway.route.application.listener;

import com.google.common.eventbus.Subscribe;
import com.lanxiao.cloud.gateway.api.GatewayDubboApi;
import com.lanxiao.cloud.modules.gateway.route.domain.event.GatewayRouteChangeEvent;
import com.lanxiao.cloud.modules.gateway.route.domain.event.GatewayRouteChangePublisher;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

/**
 * @author ：qiaoliang
 * @date ：2021-09-09
 */
@Component
public class GatewayRouteChangeListener {

  @DubboReference
  private GatewayDubboApi gatewayDubboApi;

  public GatewayRouteChangeListener(GatewayRouteChangePublisher publisher) {
    publisher.register(this);
  }

  @Subscribe
  public void changeEvent(GatewayRouteChangeEvent event){
    gatewayDubboApi.resetGatewayRoute();
  }

}
